

const KEY = 'vue_xyAdmin_token'
const USER_KEY = 'user_info'


export function setToken(value) {
    window.localStorage.setItem(KEY, value)
}
export function getToken() {
    var tokenStr = window.localStorage.getItem(KEY)
    if (!tokenStr || tokenStr == 'underfind') {
        return null
    } else {
        return tokenStr
    }
}
export function removeToken() {
    window.localStorage.removeItem(KEY)
}
export function setUserInfo(userInfo) {
    if (userInfo) {
        var userInfoStr = JSON.stringify(userInfo)
        window.localStorage.setItem(USER_KEY, userInfoStr)
    }

}
export function getUserInfo() {
    var userInfoStr = window.localStorage.getItem(USER_KEY)
    if (!USER_KEY || USER_KEY == 'underfind') {
        return null
    } else {
        var userInfo = JSON.parse(userInfoStr)
        return userInfo
    }
}
export function removeUserInfo() {
    window.localStorage.removeItem(USER_KEY)
}
export function clearUserCache() {
    removeToken()
    removeUserInfo()
}
